package com.xingzuo.library_user.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseMvpActivity;
import com.xingzuo.library_user.R;
import com.xingzuo.library_user.R2;
import com.xingzuo.library_user.adapter.MessageAdapter;
import com.xingzuo.library_user.bean.MassageBean;
import com.xingzuo.library_user.contract.MessageContract;
import com.xingzuo.library_user.presenter.MessagePresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = AppActivityKey.MESSAGEACTIVITY)
public class MessageActivity extends BaseMvpActivity<MessagePresenter> implements MessageContract.View {
    @BindView(R2.id.iv_back)
    ImageView ivBack;
    @BindView(R2.id.rv_list)
    RecyclerView rvList;
    private List<MassageBean> list=new ArrayList<>();
    MessageAdapter adapter;
    @Override
    public MessagePresenter getPresenter() {
        return new MessagePresenter();
    }

    @Override
    public int getView() {
        return R.layout.activity_message;
    }

    @Override
    public void initView() {
        list.add(new MassageBean());
        list.add(new MassageBean());
        list.add(new MassageBean());
        list.add(new MassageBean());
        list.add(new MassageBean());
        adapter=new MessageAdapter(R.layout.item_message,list);
        rvList.setLayoutManager(new LinearLayoutManager(this));
        rvList.setAdapter(adapter);
    }

    @Override
    public void initLinsenterner() {
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                startIntent(AppActivityKey.USERDETAILACTIVITY);
            }
        });
    }

    @Override
    public void getData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R2.id.iv_back)
    public void onViewClicked() {
        finishActivity();
    }
}